package com.ncloud.common.utils;

import com.alibaba.fastjson.JSON;
import com.ncloud.common.body.Result;
import com.ncloud.common.enmus.ResultEnum;

/**
 * Created by shiqiang on 2017/6/23.
 */
public class ResultUtil {
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static Result success(Object object){
        Result result = new Result(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMessage());
        result.setData(JSON.parse(JSON.toJSONString(object)));
        return result;
    }

    /*成功无返回*/
    @SuppressWarnings("rawtypes")
	public static Result success(){
        return ResultUtil.success(null);
    }
    /*失败方法*/
    @SuppressWarnings("rawtypes")
	public static Result error(Integer code, String msg){
        Result result = new Result(code, msg);
        return result;
    }
}
